package capricornus.components.alert
{
	import capricornus.components.ComponentsManager;
	import capricornus.utils.MathUtils;
	
	import flash.utils.Dictionary;

	public class Alert
	{
		public function Alert()
		{
		}
		
		private static var _dict:Dictionary = new Dictionary();
		
		/**
		 * 弹出提示 
		 * @param txtMsg
		 * @param okCallBack
		 * @param title
		 * @param model 是否模态对话框，如果true，则当前只能点该对话框，其他都不能点
		 * @param cancelCallBack
		 * @return 
		 * 
		 */		
		public static function show( txtMsg:String, okCallBack:Function=null, title:String="提示", model:Boolean=false, cancelCallBack:Function=null ):int
		{
			var id:int = MathUtils.getUniqueID();
			var view:AlertView = new AlertView( model?ComponentsManager.instance.modelAlertLayer:ComponentsManager.instance.alertLayer );
			_dict[id] = view;
			view.setInfo( id, txtMsg, title, okCallBack, cancelCallBack, model );
			view.showCenter();
			
			return id;
		}
		
		public static function destroy( alertID:int ):void
		{
			var view:AlertView = _dict[alertID];
			if( view != null )
			{
				delete _dict[alertID];
				view.destroy();
			}
		}
	}
}